package com.lingx.model.impl.interpreter;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.lingx.model.impl.AbstractInterpreter;
import com.lingx.service.LingxService;
@Component
public class FileDownloadInterpreter extends AbstractInterpreter{

	private static final long serialVersionUID = -663638321838681629L;
	@Resource
	private LingxService lingxService;
	
	public FileDownloadInterpreter() {
		super("FileDownloadInterpreter","文件下载<a/>");
	}
	@Override
	public Object input(Object value) throws Exception {
		return value;
	}

	@Override
	public Object output(Object value) throws Exception {
		String uriPrev=this.lingxService.getConfigValue("lingx.file.download.path", "http://127.0.0.1");
		String temp="<a href='%s' target='_blank'>文件下载</a>";
		if(value!=null&&!"".equals(value.toString())) {
			String url=value.toString();
			if(!url.startsWith("http"))url=uriPrev+ url;
			return String.format(temp,url);
		}else return value;
	}

}
